angular.module('MyApp')
    .controller('PostsCtrl', ['$scope', 'posts', function ($scope, posts) {


        $scope.posts = posts.getAll();
        $scope.newPost = '';

        $scope.add = function () {
            posts.add($scope.newPost);
        }

        $scope.remove = function (index) {
            posts.remove(index);
        }

    }]);